/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-06-15 10:10:42
 * @LastEditTime : 2023-08-04 13:24:11
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Pages\Front\Assets\Template\CommandCenter.jsx
 * @Description  :
 */
import './Scss/CommandCenter.scss'
import { Http } from '../../../../Common/Api'
import { useState, useEffect } from 'react'
import { useEventEmitter, useRequest } from 'ahooks'

import { CommonSmallTitle } from '../Common/SmallTitle'
import { CommandBox } from '../Command/Command'
import { Options } from '../Command/Options'
import { CommandMap } from '../Command/CommandMap'
import { CommandRight } from '../Command/CommandRight'
import { CommandSoS } from '../Command/CommandSoS'

const isShow = ['heyi.ljkjkf.com', 'jtgj.ljkjkf.com']

export const CommandCenter001 = ({ sceneId, CMT_ADMIN }) => {
    const [CallList, setCallList] = useState()
    const [BroadcastList, setBroadcastList] = useState()
    const [MoniList, setMoniList] = useState()
    const { runAsync: getTalkEquipment } = useRequest(Http, { manual: true })
    useEffect(() => {
        getTalkEquipment({ url: 'getTalkEquipment' }).then(res => {
            const { helmet, ipBroadcast, camera } = res
            const CallList = JSON.parse(
                JSON.stringify(helmet)
                    .replace(/personName/g, 'title')
                    .replace(/deviceSerial/g, 'key'),
            )
            const BroadcastList = JSON.parse(
                JSON.stringify(ipBroadcast)
                    .replace(/tableName/g, 'title')
                    .replace(/deviceSerial/g, 'key'),
            )
            const MoniList = JSON.parse(
                JSON.stringify(camera)
                    .replace(/tableName/g, 'title')
                    .replace(/uuid/g, 'key'),
            ).map(item => ({ ...item, level: 2, children: [] }))
            setCallList([{ title: '呼叫中心', key: 'CommandCentreTreeTitleUuid', level: 1, children: CallList }])
            setBroadcastList([{ title: 'IP广播', key: 'LiveVideoTreeTitleUuid', level: 1, children: BroadcastList }])
            setMoniList([{ title: '现场监控', key: 'OnSiteMonitoringTreeTitleUuid', level: 1, children: MoniList }])
        })
    }, [getTalkEquipment])

    const OptionsEvent = useEventEmitter()
    const OptionsClickEvent = useEventEmitter()
    const RightBox = useEventEmitter()
    const RightBoxClose = useEventEmitter()
    const MapAddress = useEventEmitter()
    const SOSMapAddress = useEventEmitter()

    return (
        <div className="CommandCenter001">
            <div className="List">
                <CommonSmallTitle className="ItemTitle" title="通讯录列表" flex={1}>
                    <div className="ListBox">
                        <CommandBox
                            className="HeYi"
                            data={CallList}
                            type={1}
                            RightBox={RightBox}
                            RightBoxClose={RightBoxClose}
                            OptionsEvent={OptionsEvent}
                            OptionsClickEvent={OptionsClickEvent}
                            MapAddress={MapAddress}
                            CMT_ADMIN={CMT_ADMIN}
                            sceneId={sceneId}
                        />
                        {/* {isShow.includes(window.location.hostname) && (
                            <CommandBox
                                className="HeYi"
                                data={BroadcastList}
                                type={2}
                                RightBox={RightBox}
                                RightBoxClose={RightBoxClose}
                                OptionsEvent={OptionsEvent}
                                OptionsClickEvent={OptionsClickEvent}
                            />
                        )} */}
                        {/* {isShow.includes(window.location.hostname) && (
                            <CommandBox
                                className="HeYi"
                                data={MoniList}
                                type={3}
                                RightBox={RightBox}
                                RightBoxClose={RightBoxClose}
                                OptionsEvent={OptionsEvent}
                                OptionsClickEvent={OptionsClickEvent}
                            />
                        )} */}
                    </div>
                </CommonSmallTitle>
            </div>
            {/* 处理选择事件 */}
            <Options OptionsEvent={OptionsEvent} OptionsClickEvent={OptionsClickEvent} />
            {/* 额外操作窗口 */}
            <CommandRight RightBox={RightBox} RightBoxClose={RightBoxClose} />
            {/* 定位地图 */}
            {/* <CommandMap MapAddress={MapAddress} SOSMapAddress={SOSMapAddress} sceneId={sceneId} /> */}
            {/* 求救信息 */}
            {/* {isShow.includes(window.location.hostname) && <CommandSoS SOSMapAddress={SOSMapAddress} />} */}
        </div>
    )
}
